Lasso Soft Inc. > Home

[file->getattr]

Linkfile->getattr
AuthorKe Carlton
CategoryAction
Version9.x
LicensePublic Domain
Posted09 Jul 2013
Updated09 Jul 2013
More by this author...

Description

Sample Usage

local(f) = file('///tmp/myfile.txt')

#f->getattr('user.checksum')

Source Code

Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.

/*	---------------------------------------------------------------
//
//	Extended file attributes
//
//	Reference: http://en.wikipedia.org/wiki/Extended_file_attributes
*/


define file->getattr(name::string,silent::boolean=true) => {
	// 	Linux / OSX only, adjust getfattr path accordingly
	//	Example usage:	file->getattr('user.checksum')
	
	local(t = micros)
	
	local(
		p = sys_process('/usr/bin/getfattr',staticarray('--only-values','-n',#name,file_forceroot(.path)->replace('//','/')&))->wait &,
		e = #p->readerror,
		s = #p->readstring
	)
	
	handle => {#p->close}

	not #silent && #e && #e !>> `leading '/'` ? fail(-1,#e->asstring)

    return  #s || #e
}

Comments

No comments

Please log in to comment

Subscribe to the LassoTalk mail list

LassoSoft Inc. > Home

 

 

©LassoSoft Inc 2015 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft